﻿#region Disclaimer/Info
///////////////////////////////////////////////////////////////////////////////////////////////////
// MetaCollection
// 
// MetaCollection is a system to provide a standard structure, permissions and metadata service
// for content organization.
//
// This project is hosted at Google Code at http://code.google.com/p/metacollection/
//
// This project is licensed under the BSD license.  See the License.txt file for more information.
///////////////////////////////////////////////////////////////////////////////////////////////////
#endregion

using System;
using System.Linq;
using System.Linq.Expressions;
using MetaCollection.Framework.Model;
using System.Collections.Generic;
using MetaCollection.Framework.Change;

namespace MetaCollection.Framework.Repository
{
	public interface IItemRepository : IRepository
	{
		/// <summary>
		/// Gets all versions of an item
		/// </summary>
		/// <param name="id">The id of the item.</param>
		/// <param name="opt">Load Options for what data to return</param>
		/// <returns>
		/// An ItemInstance for the given Item Id or null if no object found
		/// </returns>
		IEnumerable<IItemInstance> GetItem(Guid id, LoadOptions opt);

		/// <summary>
		/// Finds an Item by Id-Version.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="version">The version.</param>
		/// <param name="opt">Load Options for what data to return</param>
		/// <returns>
		/// An ItemInstance for the given Item Id-Version or null if no object found
		/// </returns>
		IItemInstance GetItem(Guid id, int version, LoadOptions opt);

		/// <summary>
		/// Puts the item into persistant storage or updates an existing item.
		/// </summary>
		/// <param name="item"></param>
		[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists")]
		IItemInstance SaveItem(IItemInstance item, ItemChangeCollection changeCollection);

		/// <summary>
		/// Deletes the item.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <remarks>if the item does not exist then no action is performed</remarks>
		void RemoveItem(Guid id);

		/// <summary>
		/// Deletes the item.
		/// </summary>
		/// <param name="id">The id.</param>
		/// <param name="version">The version.</param>
		/// <remarks>if the item does not exist then no action is performed</remarks>
		void RemoveItem(Guid id, int version);
	
		/// <summary>
		/// Finds an item by name with a given parent.
		/// </summary>
		/// <param name="parentId">The parent id.</param>
		/// <param name="name">The name.</param>
		/// <param name="opt">Load Options for what data to return</param>
		/// <returns>an ItemInstance</returns>
		/// <remarks>Returns the published version of each item</remarks>
		IEnumerable<IItemInstance> FindByName(Guid parentId, string name, LoadOptions opt);

		/// <summary>
		/// Finds all the items with a given parent.
		/// </summary>
		/// <param name="parentId">The parent id.</param>
		/// <param name="includeIndirect">if set to <c>true</c> the children that are not directly under the parent are also included.</param>
		/// <param name="opt">Load Options for what data to return</param>
		/// <returns></returns>
		/// <remarks>Returns the published version of each item</remarks>
		IEnumerable<IItemInstance> FindByParent(Guid parentId, bool includeIndirect, LoadOptions opt);
	}
}
